package com.lijiajian.controller;

import com.lijiajian.Service.CustomerLossService;
import com.lijiajian.base.BaseController;
import com.lijiajian.base.ResultInfo;
import com.lijiajian.query.CusDevPlanQuery;
import com.lijiajian.query.CustomerLossQuery;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Controller
@RequestMapping("customerLoss")
public class CustomerLossController extends BaseController {
    @Resource
    private CustomerLossService customerLossService;


    @GetMapping("index")
    public String toIndex(){
        return "customerLoss/customerLoss";
    }

    @GetMapping("customerLossList")
    @ResponseBody
    public Map<String,Object> queryCustomerLossByParams(CustomerLossQuery customerLossQuery){
        return customerLossService.queryCustomerLossByParams(customerLossQuery);
    }

    @GetMapping("customerLossData")
    public String toCustomerLossData(Integer id, HttpServletRequest request){
        if(id!=null){
            request.setAttribute("customerLoss",customerLossService.selectByPrimaryKey(id));
        }
        return "customerLoss/customerLossData";
    }

    @PostMapping("updateCustomerLossState")
    @ResponseBody
    public ResultInfo updateCustomerLossState(Integer id,String lossReason){
        customerLossService.updateCustomerLossState(id,lossReason);
        return success("确认成功");
    }


}
